package main

import (
	"github.com/hepeichun/hotplugin"
	"log"
	"os"
	"path/filepath"
	"time"
)

func main() {
	options := hotplugin.ManagerOptions{
		Dir:    filepath.Dir(getCurrentAbPathByExecutable()) + "/plugins/",
		Suffix: ".so",
	}
	err := hotplugin.StartManager(options)
	if err != nil {
		panic(err)
		return
	}

	for true {
		time.Sleep(time.Millisecond * 200)
	}
}

// 获取当前执行程序所在的绝对路径
func getCurrentAbPathByExecutable() string {
	exePath, err := os.Executable()
	if err != nil {
		log.Fatal(err)
	}
	res, _ := filepath.EvalSymlinks(filepath.Dir(exePath))
	return res
}
